﻿using B.S.BaseData.Api.Write.Applicantion.Command.HospitalCommand;
using B.S.BaseData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BaseData.Api.Write.Controllers
{
    /// <summary>
    /// 患者管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HospitalController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public HospitalController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 患者信息新增
        /// </summary>
        /// <param name="command">患者实体</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> PatientAdd(PatientAddCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 患者信息删除
        /// </summary>
        /// <param name="command">患者参数</param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> PatientDelete([FromQuery]PatientDeleteCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 患者信息修改
        /// </summary>
        /// <param name="command">患者参数</param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> PatientUpdate(PatientUpdateCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 就诊记录信息新增
        /// </summary>
        /// <param name="command">就诊记录实体</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> HistoryOfMedicalVisitsAdd(HistoryOfMedicalVisitsAddCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 就诊记录信息删除
        /// </summary>
        /// <param name="command">就诊记录参数</param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<APIResult<int>> HistoryOfMedicalVisitsDelete([FromQuery] HistoryOfMedicalVisitsDeleteCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 就诊信息修改
        /// </summary>
        /// <param name="command">就诊参数</param>
        /// <returns></returns>
        [HttpPut]
        public async Task<APIResult<int>> HistoryOfMedicalVisitsUpdate(HistoryOfMedicalVisitsUpdateCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
